/**
 * @description 首页 controller
 */
const xss = require('xss');

const { createBlog } = require('../services/blog');

const {SuccessModel,ErrorModel }  = require('../model/ResModel');
const {createBlogFailInfo} = require('../model/ErrorInfo');

async function create({userId,content,image}){
    try {
        const blog = await createBlog({userId,content:xss(content),image});
        return new SuccessModel(blog);
    } catch (e) {
        console.error(e.messate,e.stack);
        return new ErrorModel(createBlogFailInfo);
    }
}

module.exports = {
    create
};